<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
<HEAD>
	<META HTTP-EQUIV="CONTENT-TYPE" CONTENT="text/html; charset=utf-8">
	<TITLE></TITLE>
	<META NAME="GENERATOR" CONTENT="OpenOffice.org 3.2  (Unix)">
	<META NAME="CREATED" CONTENT="0;0">
	<META NAME="CHANGED" CONTENT="20101228;16544900">
	<STYLE TYPE="text/css">
	<!--
		@page { margin: 0.79in }
		P { margin-bottom: 0.08in }
		PRE { font-family: "Times New Roman" }
	-->
	</STYLE>
</HEAD>
<BODY LANG="el-GR" DIR="LTR">
<PRE LANG="en-US"><FONT SIZE=5><B>rk3</B></FONT>

<FONT SIZE=4><SPAN LANG="en-US">Solves an initial value problem, for a single second order ordinary differ<SPAN STYLE="font-style: normal">ential equation </SPAN><SPAN STYLE="font-style: normal">without first derivative</SPAN></SPAN></FONT>


<FONT SIZE=4><SPAN LANG="en-US"><B>Example: Can be run with F5 within the ScalaLab Editor (Ctrl-E to open the editor)</B></SPAN></FONT>



<FONT SIZE=2 STYLE="font-size: 11pt"><SPAN LANG="en-US">import java.text.DecimalFormat;</SPAN></FONT>
<FONT SIZE=2 STYLE="font-size: 11pt"><SPAN LANG="en-US">import numal.*;</SPAN></FONT>

<FONT SIZE=2 STYLE="font-size: 11pt"><SPAN LANG="en-US">import java.util.Vector;</SPAN></FONT>

<FONT SIZE=2 STYLE="font-size: 11pt"><SPAN LANG="en-US">public class Test_rk3 extends Object implements AP_rk3_method {</SPAN></FONT>

<FONT SIZE=2 STYLE="font-size: 11pt"><SPAN LANG="en-US">	public static void main(String args[]) {</SPAN></FONT>

    <FONT SIZE=2 STYLE="font-size: 11pt"><SPAN LANG="en-US">boolean fi;</SPAN></FONT>
    <FONT SIZE=2 STYLE="font-size: 11pt"><SPAN LANG="en-US">int n,i;</SPAN></FONT>
    <FONT SIZE=2 STYLE="font-size: 11pt"><SPAN LANG="en-US">double x3,s,term;</SPAN></FONT>
    <FONT SIZE=2 STYLE="font-size: 11pt"><SPAN LANG="en-US">double b[]={0.25, 0.50, 0.75, 1.00};</SPAN></FONT>
    <FONT SIZE=2 STYLE="font-size: 11pt"><SPAN LANG="en-US">double e[] = new double[6];</SPAN></FONT>
    <FONT SIZE=2 STYLE="font-size: 11pt"><SPAN LANG="en-US">double d[] = new double[6];</SPAN></FONT>
    <FONT SIZE=2 STYLE="font-size: 11pt"><SPAN LANG="en-US">double x[] = new double[1];</SPAN></FONT>
    <FONT SIZE=2 STYLE="font-size: 11pt"><SPAN LANG="en-US">double y[] = new double[1];</SPAN></FONT>
    <FONT SIZE=2 STYLE="font-size: 11pt"><SPAN LANG="en-US">double z[] = new double[1];</SPAN></FONT>

    <FONT SIZE=2 STYLE="font-size: 11pt"><SPAN LANG="en-US">Test_rk3 testrk3 = new Test_rk3();</SPAN></FONT>
    <FONT SIZE=2 STYLE="font-size: 11pt"><SPAN LANG="en-US">DecimalFormat twoDigit = new DecimalFormat(&quot;0.00E0&quot;);</SPAN></FONT>
    <FONT SIZE=2 STYLE="font-size: 11pt"><SPAN LANG="en-US">DecimalFormat fiveDigit = new DecimalFormat(&quot;0.00000&quot;);</SPAN></FONT>
    <FONT SIZE=2 STYLE="font-size: 11pt"><SPAN LANG="en-US">e[1]=e[3]=1.0e-6;</SPAN></FONT>
    <FONT SIZE=2 STYLE="font-size: 11pt"><SPAN LANG="en-US">e[2]=e[4]=1.0e-6;</SPAN></FONT>
    <FONT SIZE=2 STYLE="font-size: 11pt"><SPAN LANG="en-US">System.out.println(&quot;RK3 delivers :\n&quot;);</SPAN></FONT>
    <FONT SIZE=2 STYLE="font-size: 11pt"><SPAN LANG="en-US">Vector xyzOut = new Vector();</SPAN></FONT>
    <FONT SIZE=2 STYLE="font-size: 11pt"><SPAN LANG="en-US">for (i=0; i&lt;=3; i++) {</SPAN></FONT>
      <FONT SIZE=2 STYLE="font-size: 11pt"><SPAN LANG="en-US">fi=(b[i] &lt; 0.3);</SPAN></FONT>
      <FONT SIZE=2 STYLE="font-size: 11pt"><SPAN LANG="en-US">Analytic_problems.rk3(x,0.0,b[i],y,0.0,z,1.0,testrk3,e,d,fi, xyzOut);</SPAN></FONT>
      <FONT SIZE=2 STYLE="font-size: 11pt"><SPAN LANG="en-US">x3=x[0]*x[0]*x[0];</SPAN></FONT>
      <FONT SIZE=2 STYLE="font-size: 11pt"><SPAN LANG="en-US">term=x[0];</SPAN></FONT>
      <FONT SIZE=2 STYLE="font-size: 11pt"><SPAN LANG="en-US">s=0.0;</SPAN></FONT>
      <FONT SIZE=2 STYLE="font-size: 11pt"><SPAN LANG="en-US">n=3;</SPAN></FONT>
      <FONT SIZE=2 STYLE="font-size: 11pt"><SPAN LANG="en-US">do {</SPAN></FONT>
        <FONT SIZE=2 STYLE="font-size: 11pt"><SPAN LANG="en-US">s += term;</SPAN></FONT>
        <FONT SIZE=2 STYLE="font-size: 11pt"><SPAN LANG="en-US">term=term*x3/n/(n+1);</SPAN></FONT>
        <FONT SIZE=2 STYLE="font-size: 11pt"><SPAN LANG="en-US">n += 3;</SPAN></FONT>
      <FONT SIZE=2 STYLE="font-size: 11pt"><SPAN LANG="en-US">} while (Math.abs(term) &gt; 1.0e-14);</SPAN></FONT>
      <FONT SIZE=2 STYLE="font-size: 11pt"><SPAN LANG="en-US">System.out.println(&quot;Y-YEXACT= &quot; +</SPAN></FONT>
        <FONT SIZE=2 STYLE="font-size: 11pt"><SPAN LANG="en-US">twoDigit.format(y[0]-s) + &quot;\tX= &quot; +</SPAN></FONT>
        <FONT SIZE=2 STYLE="font-size: 11pt"><SPAN LANG="en-US">x[0] + &quot;\t\tY= &quot; + fiveDigit.format(y[0]));</SPAN></FONT>
    <FONT SIZE=2 STYLE="font-size: 11pt"><SPAN LANG="en-US">}</SPAN></FONT>
<FONT SIZE=2 STYLE="font-size: 11pt"><SPAN LANG="en-US">	}</SPAN></FONT>


  <FONT SIZE=2 STYLE="font-size: 11pt"><SPAN LANG="en-US">public double fxy(double x[], double y[])</SPAN></FONT>
  <FONT SIZE=2 STYLE="font-size: 11pt"><SPAN LANG="en-US">{</SPAN></FONT>
    <FONT SIZE=2 STYLE="font-size: 11pt"><SPAN LANG="en-US">return x[0]*y[0];</SPAN></FONT>
  <FONT SIZE=2 STYLE="font-size: 11pt"><SPAN LANG="en-US">}</SPAN></FONT>
<FONT SIZE=2 STYLE="font-size: 11pt"><SPAN LANG="en-US">}</SPAN></FONT></PRE>
</BODY>
</HTML>